package com.ljkj.blockpay.presenter;

import android.content.Context;

import androidx.annotation.NonNull;

import com.kongzue.baseokhttp.HttpRequest;
import com.kongzue.baseokhttp.listener.JsonResponseListener;
import com.kongzue.baseokhttp.util.JsonMap;
import com.kongzue.baseokhttp.util.Parameter;
import com.ljkj.blockpay.basedata.BasePresenterImpl;
import com.ljkj.blockpay.basedata.BaseView;
import com.ljkj.blockpay.network.ApiToCConfig;
import com.ljkj.blockpay.presenter.inter.RealAuthentInter;

/**
 * Created by yp on 2022/3/3
 */
public class RealNameAuthentPresenter extends BasePresenterImpl<RealAuthentInter.RealAuthentInterView> implements RealAuthentInter.RealAuthentInterPresenterView{

    public RealNameAuthentPresenter(@NonNull Context context, @NonNull RealAuthentInter.RealAuthentInterView view) {
        super(context, view);
    }

    /**
     * 审批状态
     */
    @Override
    public void approvestatus() {

        HttpRequest.POST(getContext(), ApiToCConfig.USER_AUTH_STATUS, new Parameter(), new JsonResponseListener() {
            @Override
            public void onResponse(JsonMap main, Exception error) {

            }
        });
    }

    /**
     * 初级认证
     * @param cardNum
     * @param cardType
     * @param cardUri
     * @param countryCode
     * @param dateBirth
     * @param realName
     * @param sex
     * @param surname
     */
    @Override
    public void primarysubmit(String cardNum, int cardType, String cardUri, String countryCode, Integer dateBirth, String realName, int sex, String surname) {
        JsonMap jsonMap = new JsonMap();
        jsonMap.put("cardNum",cardNum);
        jsonMap.put("cardType",cardType);
        jsonMap.put("cardUri",cardUri);
        jsonMap.put("countryCode",countryCode);
        jsonMap.put("dateBirth",dateBirth);
        jsonMap.put("realName",realName);
        jsonMap.put("sex",sex);
        jsonMap.put("surname",surname);
        HttpRequest.JSONPOST(getContext(), ApiToCConfig.USER_PRIMARY_SUBMIT,jsonMap, new JsonResponseListener() {
            @Override
            public void onResponse(JsonMap main, Exception error) {
                if (main.getInt("code") == 0){
                    JsonMap mapJsonMap = jsonMap.getJsonMap("data");
                    getView().primarySuccess(mapJsonMap);

                }
            }
        });
    }

    /**
     * 高级认证
     * @param cardBackUri
     * @param cardPositiveUri
     */
    @Override
    public void seniorsubmit(String cardBackUri, String cardPositiveUri) {
        JsonMap jsonMap = new JsonMap();
        jsonMap.put("cardBackUri",cardBackUri);
        jsonMap.put("cardPositiveUri",cardPositiveUri);
        HttpRequest.JSONPOST(getContext(), ApiToCConfig.USER_SENIOR_SUBMIT,jsonMap, new JsonResponseListener() {
            @Override
            public void onResponse(JsonMap main, Exception error) {
                if (main.getInt("code") == 0){
                    JsonMap mapJsonMap = jsonMap.getJsonMap("data");
                    getView().seniorSuccess(mapJsonMap);

                }
            }
        });
    }
}
